from moodlefuse.parsers import Parser
from files import Course

class CoursesParser(Parser):

    def parse_courses(self):
        soup = self.get_parsed_data()
        courses_html = soup.find('div', attrs={'id':'inst1598'}).find('ul', attrs={'class':'list'}).findAll('li')

        return self.parse_html(courses_html, Course)

    def parse_item_name(self, html):
        return html.text.encode('utf-8')

    def parse_item_url(self, html):
        return html.find('a')['href']